# Accept the Go version for the image to be set as a build argument.
# Default to Go 1.11
# First stage: build the executable.
FROM golang:1.13 AS builder

ARG SRC_VERSION=master

RUN git clone -b ${SRC_VERSION} --depth 1 https://github.com/kbudde/rabbitmq_exporter.git \
    /go/src/github.com/kbudde/rabbitmq_exporter
WORKDIR  /go/src/github.com/kbudde/rabbitmq_exporter

RUN go get -v github.com/prometheus/promu \
    && promu build --prefix $(pwd)


FROM scratch
MAINTAINER ZhangKunpeng <zhang.kunpeng@99cloud.net>

COPY --from=builder /go/src/github.com/kbudde/rabbitmq_exporter/rabbitmq_exporter /

EXPOSE      9090

CMD ["/rabbitmq_exporter"]